num='5'
data='7 3 11 5 2'

num=int(num)
data=list(map(int,data.split()))


def buble_sort(li):
    for i in range(len(li)):
        exchange=False
        for j in range(len(li)-i-1):
            if li[j+1]<li[j]:
                li[j],li[j+1]=li[j+1],li[j]
                exchange=True
        if exchange==False:
            break

buble_sort(data)
data_new=[]

for ind,val in enumerate(data):
    data_new.append(val-ind)

avg=sum(data_new)//len(data_new)

val=0
for i in data_new:
    val+=abs(i-avg)
print(str(val))
